<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var str = "asdkhjasdkjahsdkuashdkasjhdaskjdhsa";
        console.log(str.split('').sort().join(''));
        str = str.split("").sort().join("").match(/(\w)\1*/g).reduce(function (v, t) {//v是上次的值
            console.log(v);
            return v + t[0] + "{" + t.length + "}"
        }, "");
        console.log(str)
    </script>
</body>

</html>